<template>
  <div>
    <v-header :seller="seller" v-show="main_nav_show"></v-header>
    <div class="tab border-1px" v-show="main_nav_show">
      <div class="tab-item">
        <router-link to="/goods">商品</router-link>
      </div>
      <div class="tab-item">
        <router-link to="/ratings">评论</router-link>
      </div>
      <div class="tab-item">
        <router-link to="/seller">商家</router-link>
      </div>
    </div>
    <keep-alive>
      <router-view :seller="seller"></router-view>
    </keep-alive>
    <fix-btn/>
  </div>
</template>

<script>
import { urlParse } from "common/js/util"
import header from "components/header/header.vue"
import fixBtn from './components/nav/fix_nav'
import g from "./common/js/http.js"
const response = require("./common/data/seller.json")

const ERR_OK = 0

export default {
  data() {
    return {
      seller: {
        id: (() => {
          let queryParam = urlParse()
          return queryParam.id
        })()
      },
      main_head:true
    }
  },
  created() {
    // this.$http.get('/api/seller?id=' + this.seller.id).then((response) => {
    //   response = response.body;
    //   if (response.errno === ERR_OK) {
    //     this.seller = Object.assign({}, this.seller, response.data);
    //   }
    // });
    // if (response.errno === ERR_OK) {
    //   console.log(response.data)
    //   this.seller = Object.assign({}, this.seller, response.data)
    // }
    if(!this.$route.query.shopid =='' || !this.$route.query.shopid =='undefined'){
      localStorage.setItem('shopid',this.$route.query.shopid)
    }else{
      console.log('无商家id')
    }
    this.getData()

  },
  computed: {
    main_nav_show(){
      return this.$store.state.main_tle_show
    }
  },
  components: {
    "v-header": header,
    fixBtn
  },
  methods: {
    getData() {
      var _this = this
      var shop_id = this.$route.query.shopid
      if(shop_id == ''){
        alert('无店铺信息')
        return
      }
      g.post_func("/api/v1/staff/get_shopinfo",{shop_id : shop_id}, function(data) {
        console.log(data)
        if(data.code=='401'){
          _this.$router.push('/login')
        }
        _this.seller = Object.assign({}, _this.seller, data.data)
      })
    }
  }
}
</script>

<style lang="stylus" rel="stylesheet/stylus">
@import './common/stylus/mixin.styl';

.tab {
  display: flex;
  width: 100%;
  height: 40px;
  line-height: 40px;
  // border-bottom: 1px solid rgba(7, 17, 27, 0.1)
  border-1px(rgba(7, 17, 27, 0.1));

  .tab-item {
    flex: 1;
    text-align: center;

    & > a {
      display: block;
      font-size: 14px;
      color: rgb(77, 85, 93);

      &.active {
        color: rgb(240, 20, 20);
      }
    }
  }
}
</style>
